home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / mail / listserv / utils / use_From:_address.pl.Z / use_From:_address.pl
Encoding:
Perl Script  |  1994-05-04  |  604 b   |  42 lines

  1. #!/usr/bin/perl
  2. # From: johnw@bahainvs.org (John Wiegley)
  3.  
  4. open(TEMP, "> /tmp/In.Mail.$$");
  5. select TEMP;
  6.  
  7. while( <STDIN> )
  8. {
  9.     next if( /^From / );
  10.  
  11.     if( /^From:[ \t]+([^\n]*)/ )
  12.     {
  13.         $address = $1;
  14.  
  15.         if(    $address =~ /([^\s]+)\s+\([^)]+\)/
  16.             || $address =~ /[^<]+<([^>]+)>/
  17.             || $address =~ /"[^"]+"\s+<([^>]+)>/ )
  18.         {
  19.             $address = $1 
  20.         }
  21.     }
  22.  
  23.     print;
  24. }
  25.  
  26. close(TEMP);
  27.  
  28. $now = `date`;
  29. $" = ' ';
  30.  
  31. open(CATMAIL, "| /usr/listserv/catmail @ARGV");
  32. open(TEMP, "/tmp/In.Mail.$$");
  33.  
  34. print CATMAIL "From $address $now";
  35. print CATMAIL <TEMP>;
  36.  
  37. close(TEMP);
  38. close(CATMAIL);
  39.  
  40. unlink("/tmp/In.Mail.$$");
  41.  
  42.